//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;

namespace OpenLS.Chart.UI
{
    internal class NonBarStack : ChartStack
    {
        private readonly Dictionary<int, BarStackItem> allItems = new Dictionary<int, BarStackItem>();
        private double _minimum, _maximum;
        public override double Minimum
        {
            get { return _minimum; }
        }

        public override double Maximum
        {
            get { return _maximum; }
        }

        private double previousValue;
        public override void AddValue(NumericValue value, int seriesIndex)
        {
            var i = new BarStackItem(previousValue, value);
            allItems.Add(seriesIndex, i);
            previousValue = previousValue + value.Value;
            _minimum = Math.Min(Minimum, previousValue);
            _maximum = Math.Max(Maximum, previousValue);
        }

        public override Bounds GetBounds(int seriesIndex)
        {
            return allItems[seriesIndex].bounds;
        }
        public override double GetValue(int seriesIndex)
        {
            BarStackItem item = allItems[seriesIndex];
            return item.actualValue;
        }
    }
}
